package cn.whitecao.contentcenter.feignclient.fallbackfactory;

import cn.whitecao.contentcenter.domain.dto.user.UserDTO;
import cn.whitecao.contentcenter.feignclient.UserCenterFeignClient;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author ：腼腆的老黄.
 * @date ：Created in 2019-10-08 19:59
 */
@Component
@Slf4j
public class UserCenterFeignClientFallbackFactory implements FallbackFactory<UserCenterFeignClient> {
    @Override
    public UserCenterFeignClient create(Throwable throwable) {


        return new UserCenterFeignClient() {
            @Override
            public UserDTO findById(Integer id) {
                log.warn("限流或者降级了",throwable);
                UserDTO dto = new UserDTO();
                dto.setWxNickname("赵丹宁");
                return dto;
            }

            @Override
            public UserDTO query(UserDTO userDTO) {
                return null;
            }
        };
    }
}
